import { createRouter, createWebHistory } from "vue-router";
interface childrenRoute {
  path: string;
  name?: string;
  meta?: {
    title?: string;
    hidden?: boolean;
    icon?: string;
  };
  component?: () => Promise<typeof import("* as Component")>;
  redirect?: string;
}
interface Route {
  path: string;
  name?: string;
  meta?: {
    title?: string;
    hidden?: boolean;
    icon?: string;
  };
  component?: () => Promise<typeof import("* as Component")>;
  redirect?: string;
  children?: childrenRoute[];
}

// 路由数组
const routes: Route[] = [
  // 首页
  {
    path: "/",
    name: "layout",
    meta: {
      title: "layout",
      hidden: false,
      icon: "House",
    },
    component: () => import("@/layout/index.vue"),
    redirect: "/home",
    //
    children: [
      {
        path: "/home",
        name: "首页",
        meta: {
          title: "首页",
          hidden: false,
          icon: "House",
        },
        component: () => import("@/view/home/home.vue"),
      },
    ],
  },
  // 仪表盘
  {
    path: "/dashboard",
    name: "dashboard",
    meta: {
      hidden: false,
      title: "仪表盘",
      icon: "Odometer",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      {
        path: "/dashboard",
        name: "dashboardTable",
        meta: {
          hidden: false,
          title: "仪表盘",
          icon: "Odometer",
        },
        component: () => import("@/view/dashboard/dashboard.vue"),
      },
    ],
  },
  // 用户管理
  {
    path: "/user",
    name: "user",
    meta: {
      hidden: false,
      title: "系统管理",
      icon: "Setting",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      // 用户信息
      {
        path: "/user/userAdmin",
        name: "userAdmin",
        meta: {
          hidden: false,
          title: "用户管理",
          icon: "User",
        },
        component: () => import("@/view/user/userAdmin/index.vue"),
      },
      {
        path: "/user/acl",
        name: "acl",
        meta: {
          hidden: false,
          title: "角色管理",
          icon: "Stamp",
        },
        component: () => import("@/view/user/acl/index.vue"),
      },
      {
        path: "/user/menu",
        name: "menu",
        meta: {
          hidden: false,
          title: "菜单管理",
          icon: "Management",
        },
        component: () => import("@/view/user/menu/index.vue"),
      },
    ],
  },
  // 商品管理
  {
    path: "/shop",
    name: "shop",
    meta: {
      hidden: false,
      title: "店铺管理",
      icon: "Present",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      {
        path: "/shop/shopManage",
        name: "shopManage",
        meta: {
          hidden: false,
          title: "商品管理",
          icon: "Goods",
        },
        component: () => import("@/view/shopCategory/shopManage/index.vue"),
      },
      {
        path: "/shop/shopList",
        name: "shopList",
        meta: {
          hidden: false,
          title: "商品列表",
          icon: "List",
        },
        component: () => import("@/view/shopCategory/shopList/index.vue"),
      },
      {
        path: "/shop/shopMoney",
        name: "shopMoney",
        meta: {
          hidden: false,
          title: "收银台",
          icon: "Money",
        },
        component: () => import("@/view/shopCategory/shopMoney/index.vue"),
      },
    ],
  },
  // 模板
  {
    path: "/template",
    name: "template",
    meta: {
      hidden: false,
      title: "模板",
      icon: "Grid",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      {
        path: "/template/lotTemplate",
        name: "lotTemplate",
        meta: {
          hidden: false,
          title: "模板",
          icon: "Grid",
        },
        component: () => import("@/view/template/lotTemplate/index.vue"),
      },
    ],
  },
  // 个人信息
  {
    path: "/person",
    name: "person",
    meta: {
      hidden: false,
      title: "个人信息",
      icon: "User",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      {
        path: "/personMessage",
        name: "personMessage",
        meta: {
          hidden: false,
          title: "个人信息",
          icon: "User",
        },
        component: () => import("@/view/person/person.vue"),
      },
    ],
  },
  // GPT问答
  {
    path: "/ai",
    name: "ai",
    meta: {
      hidden: false,
      title: "GPT 问答",
    },
    component: () => import("@/layout/index.vue"),
    children: [
      {
        path: "/ai/aiQuestion",
        name: "aiQuestion",
        meta: {
          hidden: false,
          title: "GPT 问答",
          icon: "ChatDotSquare",
        },
        component: () => import("@/view/Ai/aiQuestion.vue"),
      },
    ],
  },
  // 数据大屏
  {
    path: "/dataScreen",
    name: "数据大屏",
    meta: {
      title: "数据大屏",
      hidden: false,
      icon: "DataBoard",
    },
    component: () => import("@/view/dataScreen/dataScreen.vue"),
  },
  // layout页面
  {
    path: "/",
    meta: {
      title: "layout",
      hidden: true,
    },
    redirect: "/layout",
  },
  // 404页面
  {
    path: "/404",
    name: "404",
    meta: {
      title: "404",
      hidden: true,
    },
    component: () => import("@/view/404/404.vue"),
  },
  // 任意路由
  {
    path: "/:pathMatch(.*)*",
    name: "404",
    meta: {
      title: "任意路由",
      hidden: true,
    },
    component: () => import("@/view/404/404.vue"),
  },
  // 登录
  {
    path: "/login",
    name: "登录",
    meta: {
      title: "登录",
      hidden: true,
    },
    component: () => import("@/view/login/login.vue"),
  },
  // 注册
  {
    path: "/regin",
    name: "注册",
    meta: {
      title: "注册",
      hidden: true,
    },
    component: () => import("@/view/regin/regin.vue"),
  },
];
//
const router = createRouter({
  routes: routes as [],
  history: createWebHistory(),
});
//
export default router;
